package com.lepu.app.fun.chat.bean;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.database.Cursor;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lepu.app.fun.chat.util.Constants;
import com.lepu.app.fun.chat.util.TimeUtil;

public class BeanDoctorMy {

	public String DoctorID;// 医生ID int N ListInfo
	public String DoctorName;// 医生姓名 String N ListInfo
	public String UniqueID;// 头像地址 String Y ListInfo
	public String Gender;// 性别 int Y ListInfo
	public String Age;// 年龄 String Y ListInfo
	public String HospitalName;// 医院名称 String Y ListInfo
	public String DepartmentName;// 部门名称 String Y ListInfo
	public String MobilePhone;// 手机号 String Y ListInfo
	public String JobTitle;// 技术职称 String Y ListInfo
	public String TeachJobTitle;// 教学职称 String Y ListInfo
	public int Status = Constants.Relation.RELATION_CODE_NORMAL;// 1表示有关系，2表示主动解除关系，3表示对方解除关系
	public String BindingStatus;// 是否绑定 String Y ListInfo 0-未绑定用户 1-已绑定用户

	// 接口文档没写
	public String RecordCreateTime;//
	public String ParentInstitutionID;//
	public String Birthday;//
	public String HospitalID;//
	public String DepartmentID;//
	public Date CreatedRealtionTime;

	public String Alpha;

	public static ArrayList<BeanDoctorMy> parseListInfo(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONArray jsonArray = obj1.getJSONArray("ListInfo");

			result = jsonArray.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		ArrayList<BeanDoctorMy> dataList = gson.fromJson(result,
				new TypeToken<List<BeanDoctorMy>>() {
				}.getType());
		return dataList;
	}

	public static BeanDoctorMy parseDatabase(Cursor c) {
		BeanDoctorMy doctor = new BeanDoctorMy();

		doctor.DoctorID = c.getString(c.getColumnIndex("DoctorId"));
		doctor.DoctorName = c.getString(c.getColumnIndex("NickName"));
		doctor.UniqueID = c.getString(c
				.getColumnIndex("ProfilePictureThumbnailId"));
		doctor.Gender = c.getString(c.getColumnIndex("Gender"));
		doctor.Age = c.getString(c.getColumnIndex("Age"));
		doctor.HospitalName = c.getString(c.getColumnIndex("HospitialName"));
		doctor.DepartmentName = c.getString(c.getColumnIndex("DeptmentName"));
		doctor.JobTitle = c.getString(c.getColumnIndex("JobTitle"));
		doctor.TeachJobTitle = c.getString(c.getColumnIndex("TeachingTitle"));

		// doctor.ServiceProductId =
		// c.getString(c.getColumnIndex("ServiceProductId"));
		// doctor.ServiceProductName =
		// c.getString(c.getColumnIndex("ServiceProductName"));
		// doctor.ServiceProductIconId =
		// c.getString(c.getColumnIndex("ServiceProductIconId"));
		doctor.CreatedRealtionTime = TimeUtil.getUtcDateTime(c.getString(c
				.getColumnIndex("CreatedRelationTime")));
		doctor.Status = c.getInt(c.getColumnIndex("Status"));

		doctor.Alpha = c.getString(c.getColumnIndex("Alpha"));

		return doctor;
	}

}
